{% include "header.tpl" %}
<script type="text/javascript">
	window.onload = function() {
		var base = new dhtmlXLayoutObject('container', '2U', 'dhx_skyblue');
        base.cont.obj._offsetTop = 60;
        base.cont.obj._offsetLeft = 30;
		base.cells("b").setWidth(300);
		base.cells("a").hideArrow();

		var text = base.cells("a").setText("Settings");
		var text = base.cells("b").setText("Help");

		var toolbar = base.attachToolbar();
		toolbar.setIconsPath("images/");
		toolbar.setIconSize(48);

		// adding a home link for default
		toolbar.addButton('home', 'Home', 'Home');
		toolbar.setItemImage('home', 'Home.png');
		toolbar.setItemToolTip('home', 'Home');
		toolbar.attachEvent("onClick", function(id) {
			menuButtons(id);
		});
		// build the menus dynamically from ajax call to controller
		$.getJSON('core/getMenu', function(data) {
			$.each(data, function(key, value) {
				buildToolbar(value, toolbar);
			})
		})
		// status bar
		var statusBar = base.attachStatusBar();
		statusBar.setText("Simple Status Bar");

		// create accordion for each area's settings
		var settingsPanel = base.cells("a").attachAccordion();
		settingsPanel.setIconsPath("js/lib/dhtmlxAccordion/codebase/imgs/");
		settingsPanel.setEffect(true);
		var item0 = settingsPanel.addItem('system', 'Base Settings');
		var item1 = settingsPanel.addItem('projects', 'Projects');
		var item2 = settingsPanel.addItem('tickets', 'Tickets');
		var item3 = settingsPanel.addItem('wiki', 'Knowledge Base');

		settingsPanel.cells('system').open();

		settingsPanel.cells("system").attachObject("base_settings");
		settingsPanel.cells("projects").attachObject("projects_settings");
		settingsPanel.cells("tickets").attachObject("tickets_settings");
		settingsPanel.cells("wiki").attachObject("wiki_settings");

		// this should be displaying a form but it isn't
		var form0 = settingsPanel.cells('system').attachForm();
		form0.loadStruct('xml/base_settings.xml');

		var item1 = settingsPanel.attachEvent("onActive", getContent('projects_settings'));
		var item2 = settingsPanel.attachEvent("onActive", getContent('tickets_settings'));
		var item3 = settingsPanel.attachEvent("onActive", getContent('wiki_settings'));
	}
	getContent = function(name) {
		var url = "settings/" + name;
		$("#" + name).load(url);
	}
</script>
</head>
<body>
    <div id="container">
        <div id="header">
            <span id='header_text'>Encompass</span>
            <br />
            <span id='tagline'>Project Management</span>
        </div>
        <div id="base_settings"></div>
        <div id="projects_settings"></div>
        <div id="tickets_settings"></div>
        <div id="wiki_settings"></div>
    </div>
    <div id="footer"></div>
</body>
</html> 
